//
//  UIColor+Additions.m
//  Waiguofang
//
//  Created by waiguofang on 14-8-27.
//
//

#import "UIColor+Additions.h"
#import <CoreGraphics/CGColor.h>

@implementation UIColor (Additions)

+(UIColor*)colorWithHex:(uint)hex alpha:(CGFloat)alpha
{
	int red, green, blue;
	
	blue = hex & 0x0000FF;
	green = ((hex & 0x00FF00) >> 8);
	red = ((hex & 0xFF0000) >> 16);
	
	return [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:alpha];
}

+ (UIColor*)wgfBlackColor
{
    return [self colorWithHex:0x222222 alpha:1];
}

+(CGColorRef) getColorFromRed:(int)red Green:(int)green Blue:(int)blue Alpha:(int)alpha
{
    CGFloat r = (CGFloat) red/255.0;
    CGFloat g = (CGFloat) green/255.0;
    CGFloat b = (CGFloat) blue/255.0;
    CGFloat a = (CGFloat) alpha/255.0;
    CGFloat components[4] = {r,g,b,a};
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    
    CGColorRef color = (CGColorRef)CGColorCreate(colorSpace, components);
    
    CGColorSpaceRelease(colorSpace);
    
    return color;
}



@end
